﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_GetRemainStaff]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_GetRemainStaff];
GO
CREATE PROCEDURE [dbo].[sproc_GetRemainStaff]
@staffids nvarchar(300)

AS
IF(@staffids='')
BEGIN
    SELECT * FROM UDS_STAFF WHERE Dimission=0
END
ELSE
    EXEC('SELECT * FROM UDS_STAFF WHERE Staff_ID NOT IN (SELECT Staff_ID FROM UDS_STAFF WHERE  Staff_ID IN ('+@staffids+') ) AND Dimission=0')